home *** CD-ROM | disk | FTP | other *** search
/ HyperLib 1997 Winter - Disc 1 / HYPERLIB-1997-Winter-CD1.ISO.7z / HYPERLIB-1997-Winter-CD1.ISO / オンラインウェア / COM / LineShare 3.3.1 folder.sit / LineShare 3.3.1 folder / LineShare 3.3.1 / LineShare Scripts / Motrolla Fax1&ARA&Data < prev    next >
Text File  |  1995-02-24  |  8KB  |  408 lines

  1. ! Version 3.1.4
  2. !
  3. !$ Use this script with Motorolla Power 28.8 modems
  4. !$ Supports: fax class 1, ARA and regular data incoming calls.
  5.  
  6. ^2 Speaker On:        = Enum("Never" = "0","During Connect" = "1", "Always"="2") "1"
  7. ^3 Speaker Volume:       = Enum("Low"="1","Medium"="2","High"="3") "2"
  8. ^4 Answer On:         = Enum("1 Ring"="1","2 Rings"="2","3 Rings"="3","5 Rings"="5","7 Rings"="7") "2"
  9. ^5 Port Speed:        = Enum("9600","19200","38400","57600") "38400"
  10. ^6 Handshake wires:   = Bool("Both"="¥Q3&D0","CTS only"="¥Q2&D2") "¥Q2&D2"
  11. ! ------------------------------------------
  12. ! Resetting the modem:
  13. ! ------------------------------------------
  14. @Hangup
  15.   SetTries 2
  16.   Flush
  17.   HsReset 0,0,17,19,0,0
  18.   DtrSet
  19. !
  20. ! Try to catch the "OK" answer, use the Escape seq and DTR transitions
  21. ! to enter the command mode
  22. !
  23. @Label 1
  24.   matchclr
  25.   matchstr 1 2 "OK¥r¥n"
  26.   write "ATH0&F¥r"
  27.   matchread 20
  28.   ChrDelay 1
  29.   Write "+++"
  30.   ChrDelay 0
  31.   DtrClear
  32.   SBreak
  33.   DtrSet
  34. !
  35.   DecTries
  36.   IfTries 0 1
  37. !
  38. ! OSErr -6019 "Modem error - the modem is not responding"
  39. !
  40.   exit -6019
  41. @Label 2
  42.   write "AT+FCLASS=0¥r"
  43.   Jsr 100
  44.   write "AT+FAA=0¥r"
  45.   Jsr 100
  46.   exit 0
  47.  
  48. ! ------------------------------------------
  49. !    Receiving incoming calls
  50. ! ------------------------------------------
  51. @ANSWER
  52. !
  53. ! Set the modem preferred speed first
  54. !
  55.   SerReset Val("^5"),0,8,1
  56.   Jsr 80
  57.  
  58. @Label 10
  59. !
  60. ! Set the common options
  61.   Jsr 70
  62. !
  63. ! Set the communication options:
  64. ! ・ ¥N0: Normal connection (for ARA)
  65. ! ・ ¥V2:  report connection speed
  66. !
  67.   Write "AT¥¥N0¥¥V2¥r"
  68.   Jsr 100
  69. !
  70. ! Set Fax mode
  71. !
  72.   Write "AT+FCLASS=1¥r"
  73.   Jsr 100
  74.   Write "AT+FAA=1¥r"
  75.   Jsr 100
  76. !
  77. ! Tell the modem to determine the type of the incoming call
  78. ! Fetch the tube after ^4 rings
  79. !
  80.   Write "ATS0=^4V0¥r"
  81.   Jsr 110
  82. !
  83. ! Everything is ready - let's sit and wait for a call
  84. ! We'll wait for 2 minutes, then reinitiate the modem
  85. !
  86.   Note "Waiting for a fax/ARA/data callノ"
  87.   MatchClr
  88.   matchstr 02 40 "10¥r"
  89.   MatchStr 03 41 "11¥r"
  90.   MatchStr 04 42 "22¥r"
  91.   MatchStr 05 43 "12¥r"
  92.   MatchStr 06 44 "23¥r"
  93.   MatchStr 07 45 "24¥r"
  94.   MatchStr 08 46 "25¥r"
  95.   MatchStr 09 47 "26¥r"
  96.   MatchStr 10 48 "27¥r"
  97.   MatchStr 11 49 "28¥r"
  98.   MatchStr 12 50 "29¥r"
  99.   MatchStr 13 51 "30¥r"
  100.  
  101.   MatchStr 25 19 "17¥r"
  102.   matchstr 26 18 "2¥r"
  103.   matchstr 27 57 "1¥r"
  104.   matchstr 28 17 "3¥r"
  105.   matchstr 29 17 "8¥r"
  106.   matchstr 30 17 "7¥r"
  107. @Label 16
  108.   Matchread 1200
  109. @Label 17
  110.   Note "Tuning againノ"
  111.   Write "ATV1¥r"
  112.   Jsr 100
  113.   Jump 10
  114. @Label 18
  115.   Note "Ringノ"
  116.   jump 16
  117. @Label 19
  118.   Note "Fax tones detectedノ"
  119. ! IfStr 7 16 "V"
  120.   SetSpeed 19200
  121.   Jump 16
  122.  
  123. !
  124. ! Data connection has been established (we read "CONNECT")
  125. ! Put the "CONNECT" back to the buffer and attach the "Data" subPort
  126. ! if it was an incoming call, put the "RING" before the "CONNECT"
  127. !
  128. @Label 20
  129.   IfOpen "Data" 21
  130.   Jump 30
  131. @Label 21
  132.   IfOpen "ARA" 22
  133.   Jump 35
  134. @Label 22
  135.   Note "Waiting for an ARA frame"
  136.   MatchClr
  137.   MatchStr 1 23 "^$¥r"
  138.   MatchStr 2 28 "¥08¥01¥03¥14¥04¥03¥00¥08¥250¥16¥03"
  139.   MatchStr 3 29 "¥01¥27¥02¥29¥01¥02¥01¥06"
  140.   MatchRead 60
  141.   Jump 24
  142. @Label 23
  143.   QueueInput "^$¥r"
  144. @Label 24
  145.   Note "Non-ARA call"
  146.   Jump 35
  147.  
  148. @Label 28
  149.   Note "ARA 1.0 call"
  150.   Jump 30
  151. @Label 29
  152.   Note "ARA 2.0 call"
  153.   Jump 30
  154.  
  155. @Label 30
  156.   QueueInput "¥r¥nCARRIER ^B¥r¥n"  
  157.   QueueInput "¥r¥nRING¥r¥n"
  158.   Attach "ARA" (DTR)
  159.  
  160. @Label 35
  161.   GetSReg C "DATA" 4
  162.   QueueInput "¥r^CCONNECT ^B¥r^C"
  163.   ifOriginate 36
  164.   QueueInput "¥r^CRING¥r^C"
  165. @Label 36
  166.   Attach "Data" (DTR,Escape,Break)
  167.  
  168.  
  169. !
  170. ! Converting numeric responses into the verbal
  171. !
  172. @Label 40
  173.   SetVar B "2400"
  174.   Jump 20
  175. @Label 41
  176.   SetVar B "4800"
  177.   Jump 20
  178. @Label 42
  179.   SetVar B "7200"
  180.   Jump 20
  181. @Label 43
  182.   SetVar B "9600"
  183.   Jump 20
  184. @Label 44
  185.   SetVar B "12000"
  186.   Jump 20
  187. @Label 45
  188.   SetVar B "14400"
  189.   Jump 20
  190. @Label 46
  191.   SetVar B "16800"
  192.   Jump 20
  193. @Label 47
  194.   SetVar B "19200"
  195.   Jump 20
  196. @Label 48
  197.   SetVar B "21600"
  198.   Jump 20
  199. @Label 49
  200.   SetVar B "24000"
  201.   Jump 20
  202. @Label 50
  203.   SetVar B "26400"
  204.   Jump 20
  205. @Label 51
  206.   SetVar B "28800"
  207.   Jump 20
  208.  
  209. ! ------------------------------------------
  210. ! Originating a call through the "ARA" subport
  211. ! ------------------------------------------
  212. @ORIGINATE "ARA"
  213.   SerReset Val("^5"),0,8,1
  214.   Jsr 80
  215. !
  216. ! Set the common options
  217. !
  218.   Jsr 70
  219. !
  220. ! Set the Data mode:
  221. ! ・ ¥N0:Normal connection (no compression, correction - for ARA)
  222. ! ・ハS7:  time-out (90 sec) for long-distance calls
  223. ! ・ ¥V2: report connection rate
  224. !
  225.   Write "AT¥¥N0S7=90¥¥V2¥r"
  226.   Jsr 100
  227. !
  228. ! Emit the ARA script commands ("Xnn")
  229.   Jsr 60
  230. !
  231. ! Prepare to receive all error result codes, dial the number
  232. !
  233.   Jsr 90
  234.   MatchStr 1 55 "¥r¥nCONNECT ^$¥r¥n"
  235.   MatchRead 1000
  236.   Write "¥r"
  237.   Exit -6019
  238. @Label 55
  239.   QueueInput "¥r¥nCARRIER ^$¥r¥n"
  240.   Attach "ARA" (DTR)
  241.  
  242. ! ------------------------------------------
  243. ! Originating a call through the "DATA" subport
  244. ! ------------------------------------------
  245. @ORIGINATE "Data"
  246.   SerReset Val("^5"),0,8,1
  247.   Jsr 80
  248. !
  249. ! Set the common options
  250. !
  251.   Jsr 70
  252. !
  253. ! Set the Data mode:
  254. ! ・ ¥N7: Auto-reliable
  255. ! ・ハS7:  time-out (90 sec) for long-distance calls
  256. ! ・ハ¥V0: report port speed
  257. !
  258.   Write "AT¥¥N7S7=90¥¥V0¥r"
  259.   Jsr 100
  260. !
  261. ! Emit the Data commands
  262.   Jsr 60
  263. !
  264. ! Prepare to receive all error result codes, dial the number
  265. !
  266.   Jsr 90
  267.   MatchStr 1 56 "¥r¥nCONNECT "
  268.   MatchRead 1000
  269.   Write "¥r"
  270.   Exit -6019
  271. @Label 56
  272.   QueueInput "¥r¥nCONNECT "
  273.   Attach "Data" (DTR,Escape,Break)
  274.  
  275. ! ------------------------------------------
  276. ! Originating a call through the "Fax" subPort
  277. ! ------------------------------------------
  278. @ORIGINATE "Fax"
  279. !
  280. ! Set the "Fax" speed
  281. !
  282.   SerReset 19200,0,8,1
  283.   Jsr 80
  284. !
  285. ! Set the common options
  286. !
  287.   Jsr 70
  288. !
  289. ! Set the Fax mode
  290. ! ¥Q1: Xon/Xoff handshake
  291. ! &S0: DSR always on
  292. !
  293.   Write "AT&S0¥¥Q1+FCLASS=1¥r"
  294.   Jsr 100
  295. !
  296. ! Now emit all commands that the application has sent to that port,
  297. ! except "FCLASS", etc
  298. !
  299.   EmitClear "+FCLASS","V","E"
  300.   Jsr 60
  301.   Write "ATV0¥r"
  302.   Jsr 110
  303. !
  304. ! Prepare to receive all error result codes, dial the number
  305. !
  306.   MatchClr
  307.   MatchStr 01 57 "1¥r"
  308.   MatchStr 13 93 "3¥r"
  309.   MatchStr 14 94 "8¥r"
  310.   MatchStr 15 92 "7¥r"
  311.   Write "ATD^1¥r"
  312.   HsReset *
  313.   MatchRead 900
  314.   Write "¥r"
  315.   Exit -6019
  316.  
  317. !
  318. ! Fax connection has been established (we read "FAX")
  319. ! Put the +FCON back to the buffer,
  320. ! if it was an incoming call, put the "RING" before the "+FCON"
  321. ! Attach the "Fax" subPort
  322. !
  323. @Label 57
  324.   QueueInput "1¥r"
  325. ! IfStr 7 58 "V"
  326.   SetSpeed 19200
  327. @Label 58
  328.   ifOriginate 59
  329.   QueueInput "2¥r2¥r"
  330. @Label 59
  331.   Attach "Fax" (Reset(2400),IdleLimit=30)
  332.  
  333. !
  334. ! This section emits all modem commands sent from the client application
  335. ! For each set of commands the "OK" answer is awaited
  336. !
  337. @Label 60
  338.   EmitStart
  339. @Label 61
  340.   EmitCommand 62
  341.   Jsr 100
  342.   Jump 61
  343. @Label 62
  344.   return
  345. !
  346. ! This section initiates the modem before ANSWER and ORIGINATEs:
  347. ! extended responses + connect at the highest rate + speaker control +
  348. ! reset on Dtr drop + DCD valid
  349. ! Verbal responses mode, no echo 
  350. !
  351. @Label 70
  352.   Write "ATX4M^2L^3^6&C1V1E0¥r"
  353.   Jsr 100
  354.   return 
  355.  
  356. !
  357. ! This section syncronize the modem after the serial port speed switching
  358. !
  359. @Label 80
  360.   ChrDelay 1
  361.   Write "AT¥r"
  362.   ChrDelay 0
  363.   Jsr 100
  364.   return
  365. !
  366. ! Prepare to receive error result codes, send the dialing command and
  367. ! set the user's handshake mode
  368. !
  369. @Label 90
  370.   MatchClr
  371.   MatchStr 2 91 "NO DIALTONE¥r¥n"
  372.   MatchStr 3 92 "BUSY¥r¥n"
  373.   MatchStr 4 93 "NO CARRIER¥r¥n"
  374.   MatchStr 5 94 "NO ANSWER¥r¥n"
  375.   Write "ATD^1¥r"
  376.   HsReset *
  377.   return
  378. @Label 91
  379.   exit -6020
  380. @Label 92
  381.   exit -6022
  382. @Label 93
  383.   exit -6021
  384. @Label 94
  385.   exit -6023
  386. !
  387. ! Processing the AT command:
  388. ! OK -> proceed
  389. ! ERROR or TimeOut ->exit -6019
  390. ! It can be called AFTER the "Write" command, since LineShare buffers input
  391. !
  392. @Label 100
  393.   MatchClr
  394.   MatchStr 1 103 "¥r¥nOK¥r¥n"
  395.   MatchStr 2 102 "¥r¥nERROR¥r¥n"
  396. @Label 101
  397.   MatchRead 20
  398. @Label 102
  399.   Exit -6019
  400. @Label 103
  401.   return
  402.  
  403. @Label 110
  404.   MatchClr
  405.   MatchStr 1 103 "0¥r"
  406.   MatchStr 2 102 "4¥r"
  407.   Jump 101
  408.